#include <command.h>
#include <stdio.h>
#include <string.h>
#include <errno.h>

int cmd_usage(const struct cmd *cmd)
{
	if (!cmd || IS_ERR(cmd))
		return -EINVAL;

	printf("%s - %s\n\n", cmd->name, cmd->help);
	printf("Usage:\n  %s\n", cmd->usage);
	return 0;
}

struct cmd *cmd_search(const char *name)
{
	struct cmd *cmdp;

	if (!name || (*name == '\0'))
		return ERR_PTR(-EINVAL);

	for_each_command(cmdp) {
		if (strcmp(name, cmdp->name) == 0) 
			return cmdp;
	}

	return NULL;
}

